/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jps.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Vinicio Gomez
 */
@Entity
@Table(name = "carpoollist")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Carpoollist.findAll", query = "SELECT c FROM Carpoollist c"),
    @NamedQuery(name = "Carpoollist.findById", query = "SELECT c FROM Carpoollist c WHERE c.id = :id"),
    @NamedQuery(name = "Carpoollist.findByInteres", query = "SELECT c FROM Carpoollist c WHERE c.interes = :interes"),
    @NamedQuery(name = "Carpoollist.findByCosto", query = "SELECT c FROM Carpoollist c WHERE c.costo = :costo"),
    @NamedQuery(name = "Carpoollist.findByEmail", query = "SELECT c FROM Carpoollist c WHERE c.email = :email"),
    @NamedQuery(name = "Carpoollist.findByMaximo", query = "SELECT c FROM Carpoollist c WHERE c.maximo = :maximo")})
public class Carpoollist implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "ID")
    private String id;
    @Size(max = 30)
    @Column(name = "Interes")
    private String interes;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Costo")
    private short costo;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "Email")
    private String email;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Maximo")
    private short maximo;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "id")
    private Collection<Carpoolchoose> carpoolchooseCollection;
    @JoinColumn(name = "Zona", referencedColumnName = "zona")
    @ManyToOne(optional = false)
    private Zona zona;
    @JoinColumn(name = "Horario", referencedColumnName = "Horario")
    @ManyToOne(optional = false)
    private Horario horario;
    @JoinColumn(name = "Dia", referencedColumnName = "dia")
    @ManyToOne(optional = false)
    private Dia dia;

    public Carpoollist() {
    }

    public Carpoollist(String id) {
        this.id = id;
    }

    public Carpoollist(String id, short costo, String email, short maximo) {
        this.id = id;
        this.costo = costo;
        this.email = email;
        this.maximo = maximo;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getInteres() {
        return interes;
    }

    public void setInteres(String interes) {
        this.interes = interes;
    }

    public short getCosto() {
        return costo;
    }

    public void setCosto(short costo) {
        this.costo = costo;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public short getMaximo() {
        return maximo;
    }

    public void setMaximo(short maximo) {
        this.maximo = maximo;
    }

    @XmlTransient
    public Collection<Carpoolchoose> getCarpoolchooseCollection() {
        return carpoolchooseCollection;
    }

    public void setCarpoolchooseCollection(Collection<Carpoolchoose> carpoolchooseCollection) {
        this.carpoolchooseCollection = carpoolchooseCollection;
    }

    public Zona getZona() {
        return zona;
    }

    public void setZona(Zona zona) {
        this.zona = zona;
    }

    public Horario getHorario() {
        return horario;
    }

    public void setHorario(Horario horario) {
        this.horario = horario;
    }

    public Dia getDia() {
        return dia;
    }

    public void setDia(Dia dia) {
        this.dia = dia;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Carpoollist)) {
            return false;
        }
        Carpoollist other = (Carpoollist) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        //return "jps.entities.Carpoollist[ id=" + id + " ]";
        return id;
    }
    
}
